package com.logistics.organization.entity.model;

import com.logistics.organization.entity.domain.Organization;
import com.logistics.utils.aspect.annotation.Dictionary;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;
import java.util.List;

@Data
public class OrganizationRow {

    private Integer id;

    private String name;

    private String code;

    @Dictionary(key = "organization_type")
    private String type;

    private String wcCode;

    private String creator;

    private String createTime;

    private String updater;

    private String updateTime;

    private Integer parentId;

    private List<OrganizationRow> children;

    public OrganizationRow(){

    }

    public OrganizationRow(Organization organization){
        this.id = organization.getId();
        this.name = organization.getName();
        this.code = organization.getCode();
        this.type = organization.getType();
        this.wcCode = organization.getWcCode();
        this.parentId = organization.getParentId();
        this.creator = organization.getCreator();
        this.createTime = DateUtils.dateToStringFormat(organization.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = organization.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(organization.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static OrganizationRow build(Organization organization){
        return new OrganizationRow(organization);
    }
}
